<!DOCTYPE html>
<html lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org">
<head th:include="/common/inc::header"/>
<body>
<form class="layui-form" style="margin-left: 35%;margin-top: 80px">
    <input name="id" id="id" type="hidden"/>
    <br/>
    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 120px">景区产品列表:</label>
        <div class="layui-input-inline">
            <button type="button" class="layui-btn layui-btn-danger j-qrcode">生成景区产品列表二维码</button>
        </div>
    </div>
    <br/>
    <div class="layui-form-item" style="margin-top: 30px">
        <div class="layui-input-block">
            <button class="layui-btn" style="margin-left: 30px;" lay-submit lay-filter="setSubmit">立即提交</button>
        </div>
    </div>
</form>
<table class="layui-table" id="grid" lay-filter="grid">
</table>
<script th:replace="/common/inc::incJs"></script>
<script>
    var form = layui.form;

    layui.use('laydate', function () {
        var laydate = layui.laydate;

        laydate.render({
            elem: '#beginDate', //指定元素
            type: 'datetime'
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#endDate', //指定元素
            type: 'datetime'
        });

    });

    $(function () {
        $.post('/backend/security/sysConfig/getById', {id: 1}, function (res) {
            if (res.code < 0) {
                layer.msg(res.message);
            } else {
                if (res.body != null) {
                    $("form").loadData(res.body);
                    form.render('select');
                } else {

                }
            }
        });
    });

    form.on('submit(setSubmit)', function (data) {
        if ($("#id").val() > 0) {
            $.post('/backend/security/sysConfig/update', data.field, function (res) {
                if (res.code < 0) {
                    layer.msg(res.message);
                } else {
                    layer.msg("系统设置上传成功");
                }
            });
        } else {
            $.post('/backend/security/sysConfig/add', data.field, function (res) {
                if (res.code < 0) {
                    layer.msg(res.message);
                } else {
                    layer.msg("系统设置上传成功");
                }
            });
        }
        return false;
    });

    $(".j-qrcode").click(function () {
        $.getJSON("/backend/security/sysConfig/getMinaQr", {
            str: "景区产品列表",
            page: "/pages/index/index?parentId=88&typeid=99&tabIndex=1"
        }, function (res) {
            if (res.code < 0) {
                layer.msg(res.message);
            } else {
                window.open(res.body, "newwindow", "height=800, width=800, top =100, left=500, toolbar=no, menubar=no, scrollbars =no, location=no");
            }
        })
    })

    $(".j-qrcode2").click(function () {
        $.getJSON("/backend/security/sysConfig/getMinaQr", {
            str: "首页酒店",
            page: "/pages/index/index?tabIndex=3"
        }, function (res) {
            if (res.code < 0) {
                layer.msg(res.message);
            } else {
                window.open(res.body, "newwindow", "height=800, width=800, top =100, left=500, toolbar=no, menubar=no, scrollbars =no, location=no");
            }
        })
    })

</script>
</body>
</html>
